package com.bosssoft.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bosssoft.entity.po.FibRoleAuthPO;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author Li kexi
 * Created on 2021/8/16.14:32
 */
public interface FibRoleAuthMapper extends BaseMapper<FibRoleAuthPO> {

    /**
     * 通过id禁用角色-权限的联系
     * @param id
     * @return
     */
    @Update("UPDATE fib_role_auth \n" +
            "SET deleted = #{status} \n" +
            "WHERE id = #{id} ")
    int banRoleAuthById(Long id, Integer status);

    @Select("SELECT DISTINCT auth_id \n" +
            "FROM fib_role_auth \n" +
            "WHERE role_id = #{roleId} ")
    List<Long> getAllAuthIdByRoleId(Long roleId);

    int updateBatch(List<FibRoleAuthPO> list);

    int updateBatchSelective(List<FibRoleAuthPO> list);

    int batchInsert(@Param("list") List<FibRoleAuthPO> list);

    int insertOrUpdate(FibRoleAuthPO record);

    int insertOrUpdateSelective(FibRoleAuthPO record);
}